﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Extensions;

namespace Tailord
{
    public partial class MagazaSiparisAyrinti : XForm
    {
        public MagazaSiparisAyrinti()
        {
            InitializeComponent();
        }

        private void MagazaSiparisAyrinti_Load(object sender, EventArgs e)
        {
            ShowOnlyBar();
            gvSiparisLines.Init("GetDetailOfRetailOrders");


            gvSiparisLines.SutunEkle("ToplamPSF", typeof(decimal), "BirimFiyat*Adet");
            gvSiparisLines.SutunEkle("IndirimTutari", typeof(decimal), "IndirimOrani*ToplamPSF/100");
            gvSiparisLines.SutunEkle("IndirimliTutar", typeof(decimal), "ToplamPSF-Isnull(IndirimTutari,0)");
            gvSiparisLines.SutunEkle("Odenen", typeof(decimal), "IndirimliTutar*OdemeOrani");
            gvSiparisLines.SutunEkle("Bakiye", typeof(decimal), "IndirimliTutar - Isnull(Odenen,0)");
            gvSiparisLines.SutunEkle("NetCiro", typeof(decimal), "IndirimliTutar/(1+KDV/100)");
            gvSiparisLines.SutunEkle("KdvTutar", typeof(decimal), "IndirimliTutar-NetCiro");
            gvSiparisLines.SutunEkle("ParaPuan", typeof(decimal), "IIF(Isnull(Puan,0) = 0, 0, NetCiro*10/100)");


            gvSiparisLines.MakeColumnInvisible("RetailOrderKId", "KayitTarihi", "Puan", "OdemeOrani");
            gvSiparisLines.MakeReadOnly();
            gvSiparisLines.SetCaptions("UrunId:Ürün", "BirimFiyat:BirimPSF");
            gvSiparisLines.FormatAsDate("TerminTarihi", "SiparisTarihi", "TeslimTarihi");
            gvSiparisLines.FormatAsNumber(2, "BirimFiyat", "ToplamPSF", "NetCiro", "KdvTutar", "IndirimTutari", "IndirimliTutar", "ParaPuan", "Odenen");
            gvSiparisLines.AddSummary("NetCiro", "KdvTutar", "IndirimTutari", "IndirimliTutar", "ToplamPSF", "ParaPuan", "Odenen", "Bakiye");

            gvSiparisLines.Columns["Bakiye"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            gvSiparisLines.Columns["Bakiye"].DisplayFormat.FormatString = "#,##0.##";


            gvSiparisLines.YanYanaGetir("Kategori:Servis");
            gvSiparisLines.YanYanaGetir("ToplamPSF:IndirimOrani");
            gvSiparisLines.YanYanaGetirCoklu("TeslimTarihi", "IndirimTutari:", "IndirimliTutar:", "KDV:", "KdvTutar:", "NetCiro:", "Odenen:", "Bakiye:");

            gvSiparisLines.BestFitColumns();
            
        }

        private void bbiGuncelle_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gvSiparisLines.VeriyiGuncelle("GetDetailOfRetailOrders");
        }
    }
}
